package com.fht.controller.statement;


import com.fht.entity.MerchantsInformation;
import com.fht.entity.ShopAssistant;
import com.fht.entity.StatementOrder;
import com.fht.from.ShopFrom;
import com.fht.from.StatementFrom;
import com.fht.service.food.MerchantsInformationService;
import com.fht.service.statement.StatementOrderService;
import com.fht.vo.LayUITableVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@Slf4j
@RequestMapping("/statement/orders")
public class StatementOrderController {


    @Autowired
    public StatementOrderService statementOrderService;

    @Autowired
    public MerchantsInformationService merchantsInformationService;

    //菜品类别展示
    @GetMapping("/index")
    public String index(Model model){

        List<MerchantsInformation> merchantsInformationList = merchantsInformationService.findAllIdAndName();
        model.addAttribute("merchantsInformationList",merchantsInformationList);

        return "statement/order/index";

    }
    //获取菜品类别信息
    @GetMapping("/list")
    @ResponseBody
    public LayUITableVO<List<StatementOrder>> list (@RequestParam(defaultValue = "1") Integer page,
                                                    @RequestParam(defaultValue = "10") Integer limit,
                                                    StatementFrom from){
        Map<String ,Object> map = new HashMap<>();
        map.put("page",page);
        map.put("limit",limit);
        map.put("from",from);

        LayUITableVO<List<StatementOrder>> vo = statementOrderService.findPage(map);


        return vo;
    }

}
